﻿using System;
using System.Text;
using System.Web;

namespace SystemX.Web
{
    public class ServiceBase : System.Web.Services.WebService
    {
        protected object GetSession(string key)
        {
            return HttpContext.Current.Session[key];
        }
        protected void SetSession(string key, object o)
        {
            HttpContext.Current.Session[key] = o;

        }
        protected bool IsLogined
        {
            get
            {
                return Utils.IsLogined;
            }
        }
        /// <summary>
        /// 当前会话用户ID
        /// </summary>
        protected string CurrentUserID
        {
            get
            {
                return Utils.CurrentUserID;
            }
        }
        protected object GetAppState(string key)
        {
            return Application[key];
        }
        protected void SetAppState(string key, object o)
        {
            Application[key] = o;
        }
		/// <summary>
		/// Get a ViewPath by convensation location. Views locates at the 'Views' folder in the site root
		/// </summary>
		/// <param name="folderName"></param>
		/// <param name="viewID"></param>
		/// <returns></returns>
		protected string ViewPath(string folderName, string viewID)
		{
			StringBuilder retVal = new StringBuilder();
			retVal.AppendFormat("~/Views/{0}/{1}.ascx", folderName, viewID);
			return retVal.ToString();
		}
		/// <summary>
		/// Get a WidgetPath by convensation location. Views locates at the 'Widgets' folder in the site root
		/// </summary>
		/// <param name="widgetName"></param>
		/// <returns></returns>
		protected string WidgetPath(string widgetName) {
			return string.Format("~/Widgets/{0}/widget.ascx", widgetName);
		}
    }
}
